import java.util.ArrayList;
import java.util.List;

class Student {
    int id;
    String name;
    int studentid;
    String gender;
    List<Course> selectedCourses;
    
    public int getstudentid() {
        return studentid;
    }
    
    public Student(int studentid, String name, String gender) {
        this.studentid= studentid;
        this.name = name;
        this.gender = gender;
        this.selectedCourses = new ArrayList<>();
    }

    // 选课方法
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 成功选修课程：" + course.name);
    }

    // 退课方法
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 成功退课：" + course.name);
        } else {
            System.out.println(name + " 未选修该课程，退课失败");
        }
    }

    // 打印课表方法
    public void printCourseSchedule() {
        System.out.println("\n=====" + name + "的课表=====");
        System.out.println("学生学号：" + getstudentid());
        if (selectedCourses.isEmpty()) {
            System.out.println("当前暂无选课记录"); // 明确提示无课程
        } else {
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getId());
            System.out.println("课程名称：" + course.getName());
            System.out.println("上课地点：" + course.getLocation());
            System.out.println("上课时间：" + course.getTime());
            System.out.println("授课教师：" + course.getTeacher().getName());
        }
      }
        System.out.println("==================\n");
    }
}